/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#ifndef __QS_DiagramNode_H__
#define __QS_DiagramNode_H__

#include "Prerequisites.h"

#include <QtGui/QGraphicsItem>
#include "Transaction.h"

namespace QSThink
{
	class DiagramView;
	class DiagramEdge;

	class DiagramNode
		: public QGraphicsItem
	{
	public:
		DiagramNode(DiagramView* view, Transaction* trans);

		~DiagramNode();
		void addEdge(DiagramEdge *edge);
		QList<DiagramEdge *> edges() const;

		enum { Type = UserType + 1 };
		int type() const { return Type; }


		//void QGraphicsItem::advance ( int phase )   [virtual]
		bool advance();

		Transaction* getTransaction();
	protected:
		//QRectF QGraphicsItem::boundingRect () const   [pure virtual]
		QRectF boundingRect() const;
		
		//QPainterPath QGraphicsItem::shape () const   [virtual]
		QPainterPath shape() const;

		//void QGraphicsItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 )   [pure virtual]
		void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

	protected:
		//QVariant QGraphicsItem::itemChange ( GraphicsItemChange change, const QVariant & value )   [virtual protected]
		QVariant itemChange(GraphicsItemChange change, const QVariant &value);

		void mousePressEvent(QGraphicsSceneMouseEvent *event);
		void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

		//virtual void	hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
		void	hoverEnterEvent ( QGraphicsSceneHoverEvent * event );

		//virtual void	hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
		void	hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );

		//virtual void	hoverMoveEvent ( QGraphicsSceneHoverEvent * event )

	protected:
		DiagramView* _view;
		Transaction* _trans;//the data that will represent.
		QList<DiagramEdge *> _edgeList;//will be only two connect last day and next day
		QPointF _position;

	};
}
#endif
